package blog.util.email;

import blog.entity.Email;

import java.util.HashSet;
import java.util.Set;

public class EmailSender {
    public static Integer SENDER_AUTHORITY_NORMAL = 0;
    public static Integer SENDER_AUTHORITY_ANONYMITY = 1;
    private static EmailSender self = new EmailSender();

    public static boolean send(Email email){
        return self.sendEmail(email, SENDER_AUTHORITY_NORMAL);
    }

    public static boolean send(Email email, Integer SENDER_AUTHORITY){
        if(!self.isTrueAuthority(SENDER_AUTHORITY)) return false;
        return self.sendEmail(email, SENDER_AUTHORITY);
    }

    private Set<Integer> getAuthorityList(){
        return new HashSet<Integer>(){{
            add(SENDER_AUTHORITY_NORMAL);
            add(SENDER_AUTHORITY_ANONYMITY);
        }};
    }
    private boolean isTrueAuthority(Integer SENDER_AUTHORITY){
        for (Integer authority : getAuthorityList()) if(authority.equals(SENDER_AUTHORITY)) return true;
        return false;
    }

    private boolean sendEmail(Email email, Integer SENDER_AUTHORITY){

        return true;
    }
}
